/*    */ package com.logictech.activity.system.util;
/*    */ 
/*    */ import java.io.PrintStream;
/*    */ import java.security.MessageDigest;
/*    */ 
/*    */ public class MD5Util
/*    */ {
/* 42 */   private static final String[] hexDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", 
/* 43 */     "e", "f" };
/*    */ 
/*    */   private static String byteArrayToHexString(byte[] b)
/*    */   {
/* 12 */     StringBuffer resultSb = new StringBuffer();
/* 13 */     for (int i = 0; i < b.length; i++) {
/* 14 */       resultSb.append(byteToHexString(b[i]));
/*    */     }
/* 16 */     return resultSb.toString();
/*    */   }
/*    */ 
/*    */   private static String byteToHexString(byte b) {
/* 20 */     int n = b;
/* 21 */     if (n < 0)
/* 22 */       n += 256;
/* 23 */     int d1 = n / 16;
/* 24 */     int d2 = n % 16;
/* 25 */     return hexDigits[d1] + hexDigits[d2];
/*    */   }
/*    */ 
/*    */   public static String MD5Encode(String origin, String charsetname) {
/* 29 */     String resultString = null;
/*    */     try {
/* 31 */       resultString = new String(origin);
/* 32 */       MessageDigest md = MessageDigest.getInstance("MD5");
/* 33 */       if ((charsetname == null) || ("".equals(charsetname)))
/* 34 */         resultString = byteArrayToHexString(md.digest(resultString.getBytes()));
/*    */       else
/* 36 */         resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname)));
/*    */     } catch (Exception localException) {
/*    */     }
/* 39 */     return resultString;
/*    */   }

			
/*    */ 
/*    */   public static void main(String[] args)
/*    */   {
/* 46 */     String result = MD5Encode("捷微", "UTF-8");
/* 47 */     System.out.println("result=" + result);
/*    */   }
/*    */ }

/* Location:           /Users/guo/Desktop/P3-Core-2.1-SNAPSHOT.jar
 * Qualified Name:     org.jeecgframework.p3.core.util.MD5Util
 * JD-Core Version:    0.6.2
 */